package com.tuozixuan.redisson;

import org.redisson.Redisson;
import org.redisson.api.RHyperLogLog;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;

public class HyperLogLogDemo {

	public static void main(String[] args) {

		Config config = new Config();
		SingleServerConfig singleServerConfig = config.useSingleServer();
		singleServerConfig.setAddress("redis://192.168.80.97:6379");
		singleServerConfig.setPassword("Jkdsaik8248");
		RedissonClient redissonClient = Redisson.create(config);
		RHyperLogLog<String> hyperLogLog = redissonClient.getHyperLogLog("user-count");
		hyperLogLog.add("1");
		hyperLogLog.add("2");
		hyperLogLog.add("1");
		System.out.println(hyperLogLog.count());
		
		for (int i=0; i<10000; i++) {
			hyperLogLog.add(String.valueOf(i));
		}
		System.out.println(hyperLogLog.count());
		
		hyperLogLog.delete();
	}

}
